<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'我的團隊':'My team'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        /*列表处的样式*/
        .weui-cells {
            margin-top: 0.7rem;
            font-size: 0.7rem;
        }

        .weui-cell {
            padding: 0.4rem 0.5rem;
        }

        .weui-cell__hd {
            width: 6.0rem;
        }

        .status {
            margin-top: 0.2rem;
            font-size: 0.6rem;
        }

        .team {
            font-size: 0.6rem;
            color: #888;
        }

        .assets, .star {
            font-size: 0.6rem;
            color: #F44444;
        }

        .starnum {
            font-size: 0.6rem;
            color: #468EE6;
        }

        .weui-cell__ft {
            padding-left: 0.2rem;
            font-size: 0.7rem;
        }

        .mix,.jingji {
            display: inline-block;
            /*width: 100%;*/
            padding: 0.1rem 0.2rem;
            height: 1rem;
            line-height: 1rem;
            color: #F44444;
            /*background-color: #fff;*/
            border: none;
            text-align: right;
        }

        .look {
            margin: 0.3rem 0;
            display: inline-block;
            width: 100%;
            height: 1rem;
            line-height: 1rem;
            color: #888;
        }

        .underlevel{
            padding: 0.1rem 0.2rem;
            color: #ffffff;
            background: #F44444;
            border: 0;
            outline: 0;
            border-radius: 3px;
            margin: 2px;
        }
        .sousuo {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 25px;
            margin-top: .7rem;
        }
        .sousuo input {
            border-radius: 5%;
            background-color: #fff;
            height: 20px;
            width: 50%;
            border: 1px solid #ddd;
            border-right: none;
        }
        .sousuo a {
            background-color: red;
            color: #fff;
            border-radius: 5%;
            height: 20px;
            padding: 0 5px;
            line-height: 20px;
            border: 1px solid red;
        }
        .diya,.peizi,.jiesuan {
            padding: 0.1rem 0.2rem;
            color: #ffffff;
            background: #F44444;
            border: 0;
            outline: 0;
            border-radius: 3px;
            margin: 2px;
        }
        .sell-dlog,.sell-dlog1 {
            position: fixed;
            top: 0px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.5);
            z-index: 100;
            display: none;
        }
        .dlog {
            position: relative;
            top: 8rem;
            left: 0;
            margin: 0 auto;
            padding: 0.5rem;
            width: 13rem;
            height: auto;
            background: #fff;
            border-radius: 0.4rem;
            z-index: 200;
        }

        .sell-close,.sell-close1 {
            position: absolute;
            top: 0rem;
            right: 0rem;
            width: 2rem;
            height: 1.4rem;
            text-align: center;
            line-height: 1.4rem;
            cursor: pointer;
        }
        .sellForm,.sellForm1 {
            margin-top: 0.5rem;
            width: 100%;
            font-size: 0.65rem;
        }
        .btn {
            width: 10rem;
            height: 1.5rem;
            color: #FFFFFF;
            background: #F44444;
            border: 0;
            border-radius: 0.2rem;
            outline: 0;
            cursor: pointer;
        }
        .display {
            display: inline-block;
        }
        .false {
            display: none;
        }
        .hide1 {
            display: none;
        }
        .grey {
            background-color: #ddd;
        }
        .weui-grid:before {
            border: none;
        }
        .weui-grid:after {
            border: none;
        }
        .weui-grid {
            padding: 20px 5px;
            text-align: center;
        }
        .jingji {
            font-size: 18px;
            font-weight: bold;
        }
        .hide {
            background: none;
        }
    </style>
</head>
<body>
<header class="navbar">
    <a href="{:url('index/index')}" class="navbar-item">
        <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
    </a>
    <div class="navbar-center">{$is_language?'我的團隊':'My team'}</div>
    <div class="navbar-item1">
        <select name="" id="yy">
            <option value="1" {$is_language?'selected':''}>中文</option>
            <option value="0" {$is_language?'':'selected'}>English</option>
        </select>
    </div>
</header>
{if $_SESSION['dolphin_admin_']['home_user']['group_id']==2}
<div class="sousuo">
        <!--<select name="" id="ss">-->
            <!--<option value="">选择类别</option>-->
            <!--<option value="is_balance">{$is_language?'結算商':'balance'}</option>-->
            <!--<option value="is_brokers">{$is_language?'經紀商':'brokers'}</option>-->
            <!--<option value="is_capital">{$is_language?'融資商':'capital'}</option>-->
            <!--<option value="is_mortgage">{$is_language?'抵押商':'mortgage'}</option>-->
        <!--</select>-->
        <input id="sousuo" type="text" placeholder="{$is_language?'請輸入用戶賬號':'please enter user name'}" value="">
        <a id="search" href="javascript:void(0);">{$is_language?'搜索':'search'}</a>
</div>
{/if}
<div class="content">
    <!--页面初始化，ajax请求内容-->
    <input type="hidden" id="group_id" value="{$_SESSION['dolphin_admin_']['home_user']['group_id']}">

</div>
<input type="hidden" name="yuyan" value="<?php echo @$is_language?>" id="yuyan">
<input type="hidden" id="url" value="{:url('get_list')}">
<!--结算商的弹出框-->
<div class="sell-dlog">
    <div class="dlog">
        <div class="sell-close">X</div>
        <form action="" class="sellForm">
            <p>
                {$is_language?'請選擇結算商等級':'Please select the settler level'}：
            </p>
            <p>
                <label><input name="balance_level" type="radio" value="3"/>{$is_language?'A級結算商':'A-level settlers'}</label>
                <label><input name="balance_level" type="radio" value="2"/>{$is_language?'B級結算商':'B-level settlers'}</label>
                <label><input name="balance_level" type="radio" value="1"/>{$is_language?'C級結算商':'C-level settlers'}</label>
            </p>
            <p>
                <input type="button" class="btn" id="js_btn" value="{$is_language?'確認':'Determine'}"/>
            </p>
        </form>
    </div>
</div>

<!--经济商的弹出框-->
<div class="sell-dlog1">
    <div class="dlog">
        <div class="sell-close1">X</div>
        <form action="" class="sellForm1">
            <p>
                {$is_language?'請選擇經濟商等級':'Please select the brokers level'}：
            </p>
            <p>
                <label><input name="brokers_level" type="radio" value="0"/>{$is_language?'普通用戶':'general user'}</label>
                <label><input name="brokers_level" type="radio" value="1"/>{$is_language?'區域經濟商':'Regional Economists'}</label>
                <label><input name="brokers_level" type="radio" value="2"/>{$is_language?'大區經紀商':'Regional Brokers'}</label>
                <label><input name="brokers_level" type="radio" value="3"/>{$is_language?'國際經紀商':'International brokers'}</label>
            </p>
            <p>
                <input type="button" class="btn" id="jj_btn" value="{$is_language?'確認':'Determine'}"/>
            </p>
        </form>
    </div>
</div>

<script src="https://cdn.bootcss.com/babel-core/5.8.23/browser.min.js"></script>
<script type="text/babel">
    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
//    $(document).on("change",'select#ss',function(){
//        var ss = $(this).val();
//        if(ss=='is_balance'){
//            $('#sousuo').val('結算商');
//        }else if(ss=='is_brokers'){
//            $('#sousuo').val('經紀商');
//        }else if(ss=='is_capital'){
//            $('#sousuo').val('融資商');
//        }else{
//            $('#sousuo').val('抵押商');
//        }
//    });
    $(function () {
        FastClick.attach(document.body);
    })
    var url = $("#url").val();
    var html = "";
    var group_id = $("#group_id").val();
    var yuyan = $('#yuyan').val();
    //    页面初始化ajax加载
    if(yuyan==1){
        $.post(url, {}, function (data) {
            var content = data.content;
            var len = data.content.length;
            console.log(data.content)
            if (data != '') {
                if(group_id == 2){
                    content.map((item)=>{
                        html += `
                        <div class="weui-cells" id="${item.id}">
                            <div class="weui-cell">
                                <div class="weui-cell__hd">
                                    <p class="nickname">昵稱:${item.nickname}</p>
                                    <p class="team">賬號:${item.username}</p>
                                    <p class="team">團隊人數${item.team_sum}人</p>
                                    <p class="assets">總資產￥${item.sum_money}</p>
                                    <p class="assets">積分￥${item.money1}</p>
                                    <p class="assets">團隊積分:${item.myteam_sum_money}</p>
                                    <p class="assets">團隊資產:${item.myteam_sum_zc_money}</p>
                                </div>
                                <div class="weui-cell__bd">

                                </div>
                                <div class="weui-cell__bd">
                                    <p class="starnum">${item.level}級</p>
                                </div>
                                <div class="weui-cell__ft">
                                    <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">轉出積分</a></p>
                                    <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">查看記錄</a></p>
                                </div>
                            </div>
                            <div class="weui-grids" style="display: flex;align-items: center">
                                <div href="" class="weui-grid js_grid" style="width: 50%;">
                                    <button type="button" class="underlevel">查看下級</button>
                                </div>
                                <div style="text-align: center;width: 50%;">
                                    <button class="jingji ${!item.is_brokers&&'hide'}">普通用戶</button><button class="jingji ${item.is_brokers==1&&'hide'}">區域經濟商</button><button class="jingji ${item.is_brokers==2&&'hide'}">大區經紀商</button><button class="jingji ${item.is_brokers==3&&'hide'}">國際經紀商</button>
                                </div>
                            </div>
                        </div>
                        <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                        <div class="add_1"></div>`;
                    })
                    $('.content').html(html);
                }else{
                    content.map((item)=>{
                        html += `
                        <div class="weui-cells" id="${item.id}"><div class="weui-cell">
                            <div class="weui-cell__hd"><p class="nickname">昵稱:${item.nickname}</p><p class="team">賬號:${item.username}</p><p class="team">團隊人數${item.team_sum}人</p>
                            <p class="assets">總資產￥${item.sum_money}</p><p class="assets">積分￥${item.money1}</p><p class="assets">團隊積分:${item.myteam_sum_money}</p><p class="assets">團隊資產:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                            </div><div class="weui-cell__bd"><p class="starnum">${item.level}級</p></div><div class="weui-cell__ft">
                            <p><button type="button" class="underlevel">查看下級</button></p>
                            </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                    })
                    $('.content').html(html);
                }
            } else {
                $.alert('暫無團隊數據！')
            }
        })
    }else{
        $.post(url, {}, function (data) {
            var content = data.content;
            var len = data.content.length;
            if (data != '') {
                if(group_id == 2){
                    content.map((item)=>{
                        html += `
                        <div class="weui-cells" id="${item.id}">
                            <div class="weui-cell">
                                <div class="weui-cell__hd">
                                    <p class="nickname">Nickname:${item.nickname}</p>
                                    <p class="team">Account:${item.username}</p>
                                    <p class="team">Team size:${item.team_sum}</p>
                                    <p class="assets">Total assets￥${item.sum_money}</p>
                                    <p class="assets">Balance￥${item.money1}</p>
                                    <p class="assets">Team balance:${item.myteam_sum_money}</p>
                                    <p class="assets">Team assets:${item.myteam_sum_zc_money}</p>
                                </div>
                                <div class="weui-cell__bd">

                                </div>
                                <div class="weui-cell__bd">
                                    <p class="starnum">${item.level}level</p>
                                </div>
                                <div class="weui-cell__ft">
                                    <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">Roll out balance</a></p>
                                    <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">View record</a></p>
                                </div>
                            </div>
                            <div class="weui-grids" style="display: flex;align-items: center">
                                <div href="" class="weui-grid js_grid" style="width: 50%;">
                                    <button type="button" class="underlevel">See lower level</button>
                                </div>
                                <div style="text-align: center;width: 50%;">
                                    <button class="jingji ${!item.is_brokers&&'hide'}">general user</button><button class="jingji ${item.is_brokers==1&&'hide'}">Regional Economists</button><button class="jingji ${item.is_brokers==2&&'hide'}">Regional Brokers</button><button class="jingji ${item.is_brokers==3&&'hide'}">International brokers</button>
                                </div>
                            </div>

                        </div>
                        <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                        <div class="add_1"></div>`;
                    })
                    $('.content').html(html);
                }else{
                    content.map((item)=>{
                        html += `
                        <div class="weui-cells" id="${item.id}"><div class="weui-cell">
                            <div class="weui-cell__hd"><p class="nickname">Nickname:${item.nickname}</p><p class="team">Account:${item.username}</p><p class="team">Team size:${item.team_sum}</p>
                            <p class="assets">Total assets￥${item.sum_money}</p><p class="assets">Balance￥${item.money1}</p><p class="assets">Team balance:${item.myteam_sum_money}</p><p class="assets">Team assets:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                            </div><div class="weui-cell__bd"><p class="starnum">${item.level}level</p></div><div class="weui-cell__ft">
                            <p><button type="button" class="underlevel">View subordinates</button></p>
                            </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                    })
                    $('.content').html(html);
                }
            } else {
                $.alert('No team data for the moment!')
            }
        })
    }

    //    搜索
    $(document).on('click', '#search', function () {
        var html2 = '';
        var username = $('#sousuo').val();
        var ss = $('#ss option:selected') .val();
        console.log(ss)
        var data = {username:username,is_balance:'',is_brokers:'',is_capital:'',is_mortgage:''};
        if(ss=='is_balance'){
            data.is_balance = 1;
        }else if(ss=='is_brokers'){
            data.is_brokers = 1;
        }else if(ss=='is_capital'){
            data.is_capital = 1;
        }else if(ss=='is_mortgage'){
            data.is_mortgage = 1;
        }
        $.post(url,data,function (data) {
            var content = data.content;
            if (data.code==0){
                $.alert(data.msg);
            }else{
                var len = content.length;
                if(yuyan==1){
                    if(group_id == 2){
                        content.map((item)=>{
                            html2 += `
                            <div class="weui-cells" id="${item.id}">
                                <div class="weui-cell">
                                    <div class="weui-cell__hd">
                                        <p class="nickname">昵稱:${item.nickname}</p>
                                        <p class="team">賬號:${item.username}</p>
                                        <p class="team">團隊人數${item.team_sum}人</p>
                                        <p class="assets">總資產￥${item.sum_money}</p>
                                        <p class="assets">積分￥${item.money1}</p>
                                        <p class="assets">團隊積分:${item.myteam_sum_money}</p>
                                        <p class="assets">團隊資產:${item.myteam_sum_zc_money}</p>
                                    </div>
                                    <div class="weui-cell__bd">

                                    </div>
                                    <div class="weui-cell__bd">
                                        <p class="starnum">${item.level}級</p>
                                    </div>
                                    <div class="weui-cell__ft">
                                        <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">轉出積分</a></p>
                                        <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">查看記錄</a></p>

                                    </div>
                                </div>
                                <div class="weui-grids" style="display: flex;align-items: center">
                                    <div href="" class="weui-grid js_grid" style="width: 50%;">
                                        <button type="button" class="underlevel">查看下級</button>
                                    </div>
                                    <div style="text-align: center;width: 50%;">
                                        <button class="jingji ${!item.is_brokers&&'hide'}">普通用戶</button><button class="jingji ${item.is_brokers==1&&'hide'}">區域經濟商</button><button class="jingji ${item.is_brokers==2&&'hide'}">大區經紀商</button><button class="jingji ${item.is_brokers==3&&'hide'}">國際經紀商</button>
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                        })
                        $('.content').html(html2);
                    }else{
                        content.map((item)=>{
                            html2 += `
                            <div class="weui-cells" id="${item.id}"><div class="weui-cell">
                            <div class="weui-cell__hd"><p class="nickname">昵稱:${item.nickname}</p><p class="team">賬號:${item.username}</p><p class="team">團隊人數${item.team_sum}人</p>
                            <p class="assets">總資產￥${item.sum_money}</p><p class="assets">積分￥${item.money1}</p><p class="assets">團隊積分:${item.myteam_sum_money}</p><p class="assets">團隊資產:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                            </div><div class="weui-cell__bd"><p class="starnum">${item.level}級</p></div><div class="weui-cell__ft">
                            <p><button type="button" class="underlevel">查看下級</button></p>
                            </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                        })
                        $('.content').html(html2);
                    }
                }else {
                    if (group_id == 2) {
                        content.map((item) => {
                            html2 += `
                            <div class="weui-cells" id="${item.id}">
                                <div class="weui-cell">
                                    <div class="weui-cell__hd">
                                        <p class="nickname">Nickname:${item.nickname}</p>
                                        <p class="team">Account:${item.username}</p>
                                        <p class="team">Team size:${item.team_sum}</p>
                                        <p class="assets">Total assets￥${item.sum_money}</p>
                                        <p class="assets">Balance￥${item.money1}</p>
                                        <p class="assets">Team balance:${item.myteam_sum_money}</p>
                                        <p class="assets">Team assets:${item.myteam_sum_zc_money}</p>
                                    </div>
                                    <div class="weui-cell__bd">

                                    </div>
                                    <div class="weui-cell__bd">
                                        <p class="starnum">${item.level}level</p>
                                    </div>
                                    <div class="weui-cell__ft">
                                        <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">Roll out balance</a></p>
                                        <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">View record</a></p>
                                    </div>
                                </div>
                                <div class="weui-grids" style="display: flex;align-items: center">
                                    <div href="" class="weui-grid js_grid" style="width: 50%;">
                                        <button type="button" class="underlevel">See lower level</button>
                                    </div>
                                    <div style="text-align: center;width: 50%;">
                                        <button class="jingji ${!item.is_brokers&&'hide'}">general user</button><button class="jingji ${item.is_brokers==1&&'hide'}">Regional Economists</button><button class="jingji ${item.is_brokers==2&&'hide'}">Regional Brokers</button><button class="jingji ${item.is_brokers==3&&'hide'}">International brokers</button>
                                    </div>
                                </div>
                            </div>
                            <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                    })
                        $('.content').html(html2);
                    } else {
                        content.map((item) => {
                            html2 += `
                            <div class="weui-cells" id="${item.id}"><div class="weui-cell">
                            <div class="weui-cell__hd"><p class="nickname">Nickname:${item.nickname}</p><p class="team">Account:${item.username}</p><p class="team">Team size:${item.team_sum}</p>
                            <p class="assets">Total assets￥${item.sum_money}</p><p class="assets">Balance￥${item.money1}</p><p class="assets">Team balance:${item.myteam_sum_money}</p><p class="assets">Team assets:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                            </div><div class="weui-cell__bd"><p class="starnum">${item.level}level</p></div><div class="weui-cell__ft">
                            <p><button type="button" class="underlevel">View subordinates</button></p>
                            </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                            <div class="add_1"></div>`;
                    })
                        $('.content').html(html2);
                    }
                }
            }
        })
    });

    //    点击获取下级
    $(document).on('click', '.underlevel', function () {
        var html1 = '';
        var id = $(this).parents('.weui-cells').next().val();
        var level = $(this).parents('.weui-cells').next().next().val();
        var yuyan = $('#yuyan').val();
        if(yuyan==1){
            $.post(url, {id: id, level: level}, function (data) {
                var len = data.content.length;
                var content = data.content;
                var ad = $('#' + id).next().next().next();
                var add = ad.html();
                if (len != '') {
                    if (add == null || add.length == 0) {
                        if(group_id == 2){
                            content.map((item) => {
                                html1 += `
                                <div class="weui-cells ${item.level % 2 == 0?'grey':''}" id="${item.id}">
                                    <div class="weui-cell">
                                        <div class="weui-cell__hd">
                                            <p class="nickname">昵稱:${item.nickname}</p>
                                            <p class="team">賬號:${item.username}</p>
                                            <p class="team">團隊人數${item.team_sum}人</p>
                                            <p class="assets">總資產￥${item.sum_money}</p>
                                            <p class="assets">積分￥${item.money1}</p>
                                            <p class="assets">團隊積分:${item.myteam_sum_money}</p>
                                            <p class="assets">團隊資產:${item.myteam_sum_zc_money}</p>
                                        </div>
                                        <div class="weui-cell__bd">

                                        </div>
                                        <div class="weui-cell__bd">
                                            <p class="starnum">${item.level}級</p>
                                        </div>
                                        <div class="weui-cell__ft">
                                            <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">轉出積分</a></p>
                                            <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">查看記錄</a></p>
                                        </div>
                                    </div>
                                    <div class="weui-grids" style="display: flex;align-items: center">
                                        <div href="" class="weui-grid js_grid" style="width: 50%;">
                                            <button type="button" class="underlevel">查看下級</button>
                                        </div>
                                        <div style="text-align: center;width: 50%;">
                                            <button class="jingji ${!item.is_brokers&&'hide'}">普通用戶</button><button class="jingji ${item.is_brokers==1&&'hide'}">區域經濟商</button><button class="jingji ${item.is_brokers==2&&'hide'}">大區經紀商</button><button class="jingji ${item.is_brokers==3&&'hide'}">國際經紀商</button>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                                <div class="add_1"></div>`;
                            })
                            ad.append(html1);
                        }else{
                            content.map((item) => {
                                html1 += `
                                <div class="weui-cells ${item.level % 2 == 0?'grey':''}" id="${item.id}"><div class="weui-cell">
                                <div class="weui-cell__hd"><p class="nickname">昵稱:${item.nickname}</p><p class="team">賬號:${item.username}</p><p class="team">團隊人數${item.team_sum}人</p>
                                <p class="assets">總資產￥${item.sum_money}</p><p class="assets">積分￥${item.money1}</p><p class="assets">團隊積分:${item.myteam_sum_money}</p><p class="assets">團隊資產:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                                </div><div class="weui-cell__bd"><p class="starnum">${item.level}級</p></div><div class="weui-cell__ft">
                                <p><button type="button" class="underlevel">查看下級</button></p>
                                </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                                <div class="add_1"></div>`;
                            })
                            ad.append(html1);
                        }
                    } else {
                        ad.empty();
                    }
                } else {
                    $.alert('暫無下級數據！');
                }
            })
        }else{
            $.post(url, {id: id, level: level}, function (data) {
                var len = data.content.length;
                var content = data.content;
                var ad = $('#' + id).next().next().next();
                var add = ad.html();
                if (len != '') {
                    if (add == null || add.length == 0) {
                        if(group_id == 2){
                            content.map((item) => {
                                html1 += `
                                <div class="weui-cells ${item.level % 2 == 0?'grey':''}" id="${item.id}">
                                    <div class="weui-cell">
                                        <div class="weui-cell__hd">
                                            <p class="nickname">Nickname:${item.nickname}</p>
                                            <p class="team">Account:${item.username}</p>
                                            <p class="team">Team size:${item.team_sum}</p>
                                            <p class="assets">Total assets￥${item.sum_money}</p>
                                            <p class="assets">Balance￥${item.money1}</p>
                                            <p class="assets">Team balance:${item.myteam_sum_money}</p>
                                            <p class="assets">Team assets:${item.myteam_sum_zc_money}</p>
                                        </div>
                                        <div class="weui-cell__bd">

                                        </div>
                                        <div class="weui-cell__bd">
                                            <p class="starnum">${item.level}level</p>
                                        </div>
                                        <div class="weui-cell__ft">
                                            <p><a href="/index.php/world/trans/index/username/${item.username}" class="mix">Roll out balance</a></p>
                                            <p><a href="/index.php/world/myteam/record_list/username/${item.username}" class="look">View record</a></p>
                                        </div>
                                    </div>
                                    <div class="weui-grids" style="display: flex;align-items: center">
                                        <div href="" class="weui-grid js_grid" style="width: 50%;">
                                            <button type="button" class="underlevel">See lower level</button>
                                        </div>
                                        <div style="text-align: center;width: 50%;">
                                            <button class="jingji ${!item.is_brokers&&'hide'}">general user</button><button class="jingji ${item.is_brokers==1&&'hide'}">Regional Economists</button><button class="jingji ${item.is_brokers==2&&'hide'}">Regional Brokers</button><button class="jingji ${item.is_brokers==3&&'hide'}">International brokers</button>
                                        </div>
                                    </div>
                                </div>
                                <input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                                <div class="add_1"></div>`;
                            })
                            ad.append(html1);
                        }else{
                            content.map((item) => {
                                html1 += `
                                <div class="weui-cells ${item.level % 2 == 0?'grey':''}" id="${item.id}"><div class="weui-cell">
                                <div class="weui-cell__hd"><p class="nickname">Nickname:${item.nickname}</p><p class="team">Account:${item.username}</p><p class="team">Team size:${item.team_sum}</p>
                                <p class="assets">Total assets￥${item.sum_money}</p><p class="assets">Balance￥${item.money1}</p><p class="assets">Team balance:${item.myteam_sum_money}</p><p class="assets">Team assets:${item.myteam_sum_zc_money}</p></div><div class="weui-cell__bd">
                                </div><div class="weui-cell__bd"><p class="starnum">${item.level}level</p></div><div class="weui-cell__ft">
                                <p><button type="button" class="underlevel">View subordinates</button></p>
                                </div></div></div><input type="hidden" value="${item.id}" class="hidid"><input type="hidden" value="${item.level}" class="hidid">
                                <div class="add_1"></div>`;
                            })
                            ad.append(html1);
                        }

                    } else {
                        ad.empty();
                    }
                } else {
                    $.alert('暫無下級數據！');
                }
            })
        }
    });

//    经济商
    $(document).on('click', '', function () {
        var url = "{:url('is_brokers')}";
        var html = $(this).html();
        var id = $(this).parents('.weui-cells').next().val();
        $(".sell-dlog1").css('display', 'block');
        $('body').css({
            "overflow-x": "hidden",
            "overflow-y": "hidden"
        });
        console.log(html)
        if (html=='普通用戶'||html=="general user"){
            $("input[name='brokers_level'][value=0]").attr("checked","checked");
        }else if (html=='區域經濟商'||html=="Regional Economists") {
            $("input[name='brokers_level'][value=1]").attr("checked","checked");
        }else if (html=='大區經紀商'||html=="Regional Brokers"){
            $("input[name='brokers_level'][value=2]").attr("checked","checked");
        }else{
            $("input[name='brokers_level'][value=3]").attr("checked","checked");
        }
        $('#jj_btn').click(function () {
            var brokers_level = $("input[name='brokers_level']:checked").val();
            console.log(brokers_level);
            $.post(url,{id:id,is_brokers:brokers_level},function (data) {
                console.log(data)
                $.alert(data.msg,function () {
                    window.location.reload();
                });
            })
        })
    })

//    结算商
    $(document).on('click', '.jiesuan', function () {
        var html = $(this).html();
        var url = "{:url('is_balance')}";
        var id = $(this).parents('.weui-cells').next().val();
        console.log(html)
        if(html=='成為結算商'||html=="Become a settler"){
            $(".sell-dlog").css('display', 'block');
            $('body').css({
                "overflow-x": "hidden",
                "overflow-y": "hidden"
            });
            //阻止默认
            $("body").on("touchmove", function (event) {
                event.preventDefault;
            }, false);
            $('#js_btn').click(function () {
                var balance_level = $("input[name='balance_level']:checked").val();
                console.log(balance_level);
                $.post(url,{id:id,balance_level:balance_level,is_balance:1},function (data) {
                    $.alert(data.msg,function () {
                        window.location.reload();
                    });
                })
            })
        }else {
            $.confirm({
                title: '提示（confirm）',
                text: '取消成為結算商？（Cancellation as a clearing house?）',
                onOK: function () {
                    $.post(url,{id:id,balance_level:0,is_balance:0},function (data) {
                        $.alert(data.msg,function () {
                            window.location.reload();
                        });
                    })
                }
            })
        }
    });

    // 抵押商
    $(document).on('click', '.diya', function () {
        var html = $(this).html();
        var id = $(this).parents('.weui-cells').next().val();
        var url = "{:url('is_mortgage')}";
        $.confirm({
            title: '提示（confirm）',
            text: '是否确认此抵押商操作？（Are you sure?）',
            onOK: function () {
                if(html=='成為抵押商'){
                    $.post(url,{id:id,is_mortgage:1},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='取消成為抵押商'){
                    $.post(url,{id:id,is_mortgage:0},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='Become a mortgage dealer'){
                    $.post(url,{id:id,is_mortgage:1},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='Cancel to become a mortgagee'){
                    $.post(url,{id:id,is_mortgage:0},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }
            }
        })
    });


    // 配资商
    $(document).on('click', '.peizi', function () {
        var html = $(this).html();
        var id = $(this).parents('.weui-cells').next().val();
        var url = "{:url('is_capital')}";
        $.confirm({
            title: '提示（confirm）',
            text: '是否确认此配資商操作？（Are you sure?）',
            onOK: function () {
                if(html=='成為配資商'){
                    $.post(url,{id:id,is_capital:1},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='取消成為配資商'){
                    $.post(url,{id:id,is_capital:0},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='Become a distributor'){
                    $.post(url,{id:id,is_capital:1},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }else if(html=='Cancel to become a distributor'){
                    $.post(url,{id:id,is_capital:0},function (data) {
                        if(data.code==1){
                            $.alert({
                                title: '提示',
                                text: data.msg,
                                onOK: function () {
                                    window.location.reload();
                                }
                            });
                        }else{
                            $.alert(data.msg);
                        }
                    })
                }
            }
        })
    });

    $('.sell-close').click(function () {
        $(".sell-dlog").css('display', 'none');
        $('body').css({
            "overflow-x": "auto",
            "overflow-y": "auto"
        });
        //然后点击取消或者确定时再取消body上的绑定
        $("body").off("touchmove");
        $('.numInput').val(1);
    });
    $('.sell-close1').click(function () {
        $(".sell-dlog1").css('display', 'none');
        $('body').css({
            "overflow-x": "auto",
            "overflow-y": "auto"
        });
        //然后点击取消或者确定时再取消body上的绑定
        $("body").off("touchmove");
    });
</script>
</body>
</html>
